package com.weaver.qfengx;

import java.util.function.BiConsumer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 正则相关工具类
 */
public class RegexUtils {

    public static void regHangle(String reg, String source, BiConsumer<Matcher, String> handler) {
        Pattern pattern = Pattern.compile(reg);
        Matcher m = pattern.matcher(source);
        while (m.find()) {
            handler.accept(m, source);
        }

    }

    public static void main(String[] args) {
        RegexUtils.regHangle("\\$\\{([a-zA-Z0-9.]+)\\}", "${qqxgwd1},${sub.sjjh1}", (m, str) -> {
            System.out.println(m.group(1));
        });
    }

}
